<?php
class Model_TaskModel
{
    protected $_table;

    public function getTable()
    {
        if (null === $this->_table) {
            require_once APPLICATION_PATH . '/models/DbTable/Task.php';
            $this->_table = new Model_DbTable_Task;
        }
        return $this->_table;
    }

    public function fetchEntries()
    {
        return $this->getTable()->fetchAll('1')->toArray();
    }

	public function fetchEntriesByUser($user)
    {
    	$table 		= $this->getTable();
        $selectOb 	= $table->select()->where('user_id = ?', $user->id);
		return $this->getTable()->fetchAll($selectOb)->toArray();
    }
	
	public function fetchEntriesByGoal($goal)
    {
		$table 		= $this->getTable();
		$selectOb 	= $table->select()->where('goal_id = ?', $goal->id);
		return $this->getTable()->fetchAll($selectOb)->toArray();
		
    }
	
}